//
//  LoginOutVm.swift
//  Pods
//
//  Created by eme on 2017/3/28.
//
//

import SwiftyJSON
import RxSwift
import ModelProtocol
import Result

class LoginOutVm{
    
    let loginOut_devid = PublishSubject<Void>()
    let disposeBag = DisposeBag()
    let error = PublishSubject<MikerError>()
    let backDate = PublishSubject<Bool>()
    let refreshing = Variable(false)
    
    init() {
        let request = loginOut_devid.map{ _ in
            
            return MineApi.loginOut()
            
            }.shareReplay(1)
        
        let response = request.emeRequestApiForRegJson().shareReplay(1)
        
        
        response.subscribe(onNext: { [unowned self] (result) in
            
            switch result{
            case .success(_):
                self.backDate.onNext(true)
            case .failure(let error):
                self.error.onNext(error)
            }
            
        }).addDisposableTo(disposeBag)
        
    }
    
}
